package com.admin.controller.scoreParam;

import com.admin.common.util.YsCollectionUtil;
import com.admin.controller.base.BaseController;
import com.admin.domain.ScoreParam;
import com.admin.domain.ScoreParamLog;
import com.admin.service.ScoreParamService;
import com.admin.vo.PageVO;
import com.admin.vo.ResultVO;
import com.admin.vo.SimpleResultVO;
import com.admin.vo.scoreParam.ScoreParamListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 评分标准配置
 * 
 * @author yangzhongliang
 * @date 2022/05/16
 */
@Api(description = "评分标准配置")
@RestController
@RequestMapping(value = "/scoreParam")
public class ScoreParamController extends BaseController {

    private Logger logger = LoggerFactory.getLogger(ScoreParamController.class);

    @Autowired
    private ScoreParamService scoreParamService;

    @ApiOperation(value = "评分标准配置-列表")
//    @RequiresPermissions("admin:list")
    @GetMapping(value = "/list")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageIndex", value = "当前页码", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query")})
    public ResultVO<PageVO<ScoreParamListVO>> listAdmins(Integer pageIndex, Integer pageSize) {
        Map<String, Object> params = YsCollectionUtil.createHashMap();
        return scoreParamService.getPageList(pageIndex, pageSize, params);
    }

    @ApiOperation(value = "评分标准配置-列表 - 详情")
    @GetMapping(value = "/detail")
    @ApiImplicitParam(name = "id", value = "主键id", required = true, dataType = "int", paramType = "query")
    public ResultVO<ScoreParam> detail(Integer id) {
        return ResultVO.ok(scoreParamService.getById(id));
    }


    @ApiOperation(value = "评分标准配置-列表 - 修改")
    @PostMapping(value = "/update")
    public SimpleResultVO update(@RequestBody ScoreParam req) {
        return scoreParamService.update(req);
    }

    @ApiOperation(value = "评分标准配置-列表 - 日志列表")
//    @RequiresPermissions("admin:list")
    @GetMapping(value = "/logList")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageIndex", value = "当前页码", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query")})
    public ResultVO<PageVO<ScoreParamLog>> logList(Integer pageIndex, Integer pageSize) {
        Map<String, Object> params = YsCollectionUtil.createHashMap();
        params.put("orderBy", "id");
        return scoreParamService.getLogPageList(pageIndex, pageSize, params);
    }


}
